﻿using System.Reflection;
using WinFormsApp1.bo;
using WinFormsApp1.outputBo;
using NPOI.SS.UserModel;

namespace ConsoleApp1.utils;

/**
 * 转换类, 负责sheet对象和类对象之间的转换
 */
public class Converter
{
    /**
     * 从单个sheet里把每一行都读出来变成一个TPSTR04
     */
    public static void fromSheetToTPSTR04List(ISheet sheet, ref List<TPSTR04> TPSTR04List)
    {
        MissingCellPolicy policy = MissingCellPolicy.CREATE_NULL_AS_BLANK;
        for (int i = 1; i <= sheet.LastRowNum; i++)
        {
            IRow row = sheet.GetRow(i);
            TPSTR04 tpstr04 = new TPSTR04();

            tpstr04.REC_CREATOR = row.GetCell(0, policy).ToString();
            tpstr04.REC_CREATE_TIME = row.GetCell(1, policy).ToString();
            tpstr04.REC_REVISOR = row.GetCell(2, policy).ToString();
            tpstr04.REC_REVISE_TIME = row.GetCell(3, policy).ToString();
            tpstr04.ARCHIVE_FLAG = row.GetCell(4, policy).ToString();
            tpstr04.ARCHIVE_STAMP_NO = row.GetCell(5, policy).ToString();
            tpstr04.PLAN_BACKLOG_CODE = row.GetCell(6, policy).ToString();
            tpstr04.PLAN_STATUS = row.GetCell(7, policy).ToString();
            tpstr04.PLAN_TYPE = row.GetCell(8, policy).ToString();
            tpstr04.PLAN_NO = row.GetCell(9, policy).ToString();
            tpstr04.PLAN_SEQ_NO = Int32.Parse(row.GetCell(10, policy).ToString());
            tpstr04.PLAN_SEQ_NO_DAY = Int32.Parse(row.GetCell(11, policy).ToString());
            tpstr04.PLAN_DATE_FROM = row.GetCell(12, policy).ToString();
            tpstr04.PLAN_DATE_TO = row.GetCell(13, policy).ToString();
            tpstr04.RL_NO = row.GetCell(14, policy).ToString();
            tpstr04.RL_ITEM_NO = row.GetCell(15, policy).ToString();
            tpstr04.ROLL_DIA = double.Parse(row.GetCell(16, policy).ToString());
            tpstr04.ROLL_WAL_THICK = double.Parse(row.GetCell(17, policy).ToString());
            tpstr04.REQR_ROLL_TUBE = Int32.Parse(row.GetCell(18, policy).ToString());
            tpstr04.REQR_ROLL_WT = double.Parse(row.GetCell(19, policy).ToString());
            tpstr04.PROD_MID_CODE = row.GetCell(20, policy).ToString();
            tpstr04.PROD_MID_CNAME = row.GetCell(21, policy).ToString();
            tpstr04.MTRL_NO = row.GetCell(22, policy).ToString();
            tpstr04.MTRL_TEXT = row.GetCell(23, policy).ToString();
            tpstr04.BILLET_DIA = double.Parse(row.GetCell(24, policy).ToString());
            tpstr04.GROOVE_CODE = row.GetCell(25, policy).ToString();
            tpstr04.GROOVE_SIZE = double.Parse(row.GetCell(26, policy).ToString());
            tpstr04.GROOVE_DESC = row.GetCell(27, policy).ToString();
            tpstr04.SUB_GROOVE_CODE = row.GetCell(28, policy).ToString();
            tpstr04.SUB_GROOVE_DESC = row.GetCell(29, policy).ToString();
            tpstr04.SUB_GROOVE_GROUP_CODE = row.GetCell(30, policy).ToString();
            tpstr04.SUB_GROOVE_TYPE_TEXT = row.GetCell(31, policy).ToString();
            tpstr04.BILLET_LEN = double.Parse(row.GetCell(32, policy).ToString());
            tpstr04.BILLET_WT = double.Parse(row.GetCell(33, policy).ToString());
            tpstr04.RAW_LEN = double.Parse(row.GetCell(34, policy).ToString());
            tpstr04.MAT_NO = row.GetCell(35, policy).ToString();
            tpstr04.MAT_KIND = row.GetCell(36, policy).ToString();
            tpstr04.PONO = row.GetCell(37, policy).ToString();
            tpstr04.CZ_RL_NO = row.GetCell(38, policy).ToString();
            tpstr04.ORIGIN_HEAT_NO = row.GetCell(39, policy).ToString();
            tpstr04.PLAN_TUBE = Int32.Parse(row.GetCell(40, policy).ToString());
            tpstr04.PLAN_WT = double.Parse(row.GetCell(41, policy).ToString());
            tpstr04.DEVO_TUBE = Int32.Parse(row.GetCell(42, policy).ToString());
            tpstr04.DEVO_WT = double.Parse(row.GetCell(43, policy).ToString());
            tpstr04.MAT_TUBE = Int32.Parse(row.GetCell(44, policy).ToString());
            tpstr04.MAT_THEORY_WT = double.Parse(row.GetCell(45, policy).ToString());
            tpstr04.MAT_ACT_WT = double.Parse(row.GetCell(46, policy).ToString());
            tpstr04.FIX_FLAG = row.GetCell(47, policy).ToString();
            tpstr04.LEN_FROM = double.Parse(row.GetCell(48, policy).ToString());
            tpstr04.LEN_TO = double.Parse(row.GetCell(49, policy).ToString());
            tpstr04.STOCK_PLACE_NO = row.GetCell(50, policy).ToString();
            tpstr04.SAW_CUT = Int32.Parse(row.GetCell(51, policy).ToString());
            tpstr04.CUT_LEN = double.Parse(row.GetCell(52, policy).ToString());
            tpstr04.CUT_WT = double.Parse(row.GetCell(53, policy).ToString());
            tpstr04.CUT_BILLET = Int32.Parse(row.GetCell(54, policy).ToString());
            tpstr04.REMAIN_LEN = double.Parse(row.GetCell(55, policy).ToString());
            tpstr04.REMAIN_BILLET = Int32.Parse(row.GetCell(56, policy).ToString());
            tpstr04.REMAIN_WT = double.Parse(row.GetCell(57, policy).ToString());
            tpstr04.START_PROD_TIME = row.GetCell(58, policy).ToString();
            tpstr04.END_PROD_TIME = row.GetCell(59, policy).ToString();
            tpstr04.PLAN_PROD_TIME = Int32.Parse(row.GetCell(60, policy).ToString());
            tpstr04.PLAN_SEND_TIME = row.GetCell(61, policy).ToString();
            tpstr04.PLAN_SEND_FLAG = row.GetCell(62, policy).ToString();
            tpstr04.PLAN_MAKER = row.GetCell(63, policy).ToString();
            tpstr04.REMARK_PS = row.GetCell(64, policy).ToString();
            tpstr04.UNRULL_FLAG = row.GetCell(65, policy).ToString();
            tpstr04.PLAN_TENDAY_FLAG = row.GetCell(66, policy).ToString();
            tpstr04.SPVISE_FLAG = row.GetCell(67, policy).ToString();
            tpstr04.COME_PROC_FLAG = row.GetCell(68, policy).ToString();
            tpstr04.BILLET_TAIL_FLAG = row.GetCell(69, policy).ToString();
            tpstr04.BILLET_USAGE_FLAG = row.GetCell(70, policy).ToString();
            tpstr04.STEEL_MAKING_METHOD_CODE = row.GetCell(71, policy).ToString();
            tpstr04.STEEL_MAKING_METHOD = row.GetCell(72, policy).ToString();
            tpstr04.BILLET_PROC_MODE_CODE = row.GetCell(73, policy).ToString();
            tpstr04.BILLET_PROC_MODE = row.GetCell(74, policy).ToString();
            tpstr04.BILLET_STRIP_CODE = row.GetCell(75, policy).ToString();
            tpstr04.BILLET_STRIP = row.GetCell(76, policy).ToString();
            tpstr04.BILLET_DIF_CODE = row.GetCell(77, policy).ToString();
            tpstr04.BILLET_DIA_STRIP = double.Parse(row.GetCell(78, policy).ToString());
            tpstr04.MAT_APP_NO = row.GetCell(79, policy).ToString();
            tpstr04.PLAN_EXEC_SEQ_NO = Int32.Parse(row.GetCell(80, policy).ToString());
            tpstr04.REMARK = row.GetCell(81, policy).ToString();
            // tpstr04.PRE_PLAN_NO = row.GetCell(82, policy).ToString();
            // tpstr04.SEQ_NOW = Int32.Parse(row.GetCell(83, policy).ToString());

            TPSTR04List.Add(tpstr04);
        }
    }

    /**
     * 从单个sheet里把每一行都读出来变成一个TPMOUTR02List
     */
    public static void fromSheetToTPMOUTR02List(ISheet sheet, ref List<TPMOUTR02> TPMOUTR02List)
    {
        MissingCellPolicy policy = MissingCellPolicy.CREATE_NULL_AS_BLANK;
        for (int i = 1; i <= sheet.LastRowNum; i++)
        {
            IRow row = sheet.GetRow(i);
            TPMOUTR02 tpmoutr02 = new TPMOUTR02();

            tpmoutr02.stat = 0;
            tpmoutr02.REC_CREATOR = row.GetCell(0, policy).ToString();
            tpmoutr02.REC_CREATE_TIME = row.GetCell(1, policy).ToString();
            tpmoutr02.REC_REVISOR = row.GetCell(2, policy).ToString();
            tpmoutr02.REC_REVISE_TIME = row.GetCell(3, policy).ToString();
            tpmoutr02.ARCHIVE_FLAG = row.GetCell(4, policy).ToString();
            tpmoutr02.ARCHIVE_STAMP_NO = row.GetCell(5, policy).ToString();
            tpmoutr02.RL_NO = row.GetCell(6, policy).ToString();
            tpmoutr02.RL_ITEM_NO = row.GetCell(7, policy).ToString();
            tpmoutr02.RL_GROUP_DATE = row.GetCell(8, policy).ToString();
            tpmoutr02.ROLL_DIA = double.Parse(row.GetCell(9, policy).ToString());
            tpmoutr02.ROLL_WAL_THICK = double.Parse(row.GetCell(10, policy).ToString());
            tpmoutr02.ROLL_LEN_FROM = Int32.Parse(row.GetCell(11, policy).ToString());
            tpmoutr02.ROLL_LEN_TO = Int32.Parse(row.GetCell(12, policy).ToString());
            tpmoutr02.MAKE_METHOD_CODE = row.GetCell(13, policy).ToString();
            tpmoutr02.MAKE_METHOD = row.GetCell(14, policy).ToString();
            tpmoutr02.PROD_MID_CODE = row.GetCell(15, policy).ToString();
            tpmoutr02.PROD_MID_CNAME = row.GetCell(16, policy).ToString();
            tpmoutr02.ST_NO = row.GetCell(17, policy).ToString();
            tpmoutr02.MTRL_NO = row.GetCell(18, policy).ToString();
            tpmoutr02.MTRL_TEXT = row.GetCell(19, policy).ToString();
            tpmoutr02.GROOVE_CODE = row.GetCell(20, policy).ToString();
            tpmoutr02.GROOVE_SIZE = double.Parse(row.GetCell(21, policy).ToString());
            tpmoutr02.GROOVE_DESC = row.GetCell(22, policy).ToString();
            tpmoutr02.SUB_GROOVE_CODE = row.GetCell(23, policy).ToString();
            tpmoutr02.SUB_GROOVE_DESC = row.GetCell(24, policy).ToString();
            tpmoutr02.SUB_GROOVE_GROUP_CODE = row.GetCell(25, policy).ToString();
            tpmoutr02.SUB_GROOVE_TYPE_TEXT = row.GetCell(26, policy).ToString();
            tpmoutr02.BILLET_DIF_CODE = row.GetCell(27, policy).ToString();
            tpmoutr02.STEEL_MAKING_METHOD_CODE = row.GetCell(28, policy).ToString();
            tpmoutr02.STEEL_MAKING_METHOD = row.GetCell(29, policy).ToString();
            tpmoutr02.BILLET_STRIP_CODE = row.GetCell(30, policy).ToString();
            tpmoutr02.BILLET_STRIP = row.GetCell(31, policy).ToString();
            tpmoutr02.BILLET_PROC_MODE_CODE = row.GetCell(32, policy).ToString();
            tpmoutr02.BILLET_PROC_MODE = row.GetCell(33, policy).ToString();
            tpmoutr02.BILLET_DIA_STRIP = double.Parse(row.GetCell(34, policy).ToString());
            tpmoutr02.BILLET_DIA = double.Parse(row.GetCell(35, policy).ToString());
            tpmoutr02.BILLET_WT_PER_METER = double.Parse(row.GetCell(36, policy).ToString());
            tpmoutr02.BILLET_LEN = double.Parse(row.GetCell(37, policy).ToString());
            tpmoutr02.BILLET_WT = double.Parse(row.GetCell(38, policy).ToString());
            tpmoutr02.RAW_LEN = double.Parse(row.GetCell(39, policy).ToString());
            tpmoutr02.MANDREL_DIA = double.Parse(row.GetCell(40, policy).ToString());
            tpmoutr02.MANDREL_ADJ = double.Parse(row.GetCell(41, policy).ToString());
            tpmoutr02.PIERC_DIA = double.Parse(row.GetCell(42, policy).ToString());
            tpmoutr02.PIERC_WAL_THICK = double.Parse(row.GetCell(43, policy).ToString());
            tpmoutr02.PIERC_LEN = double.Parse(row.GetCell(44, policy).ToString());
            tpmoutr02.SIZING_DIA = double.Parse(row.GetCell(45, policy).ToString());
            tpmoutr02.SIZING_WAL_THICK = double.Parse(row.GetCell(46, policy).ToString());
            tpmoutr02.SIZING_LEN = double.Parse(row.GetCell(47, policy).ToString());
            tpmoutr02.ROLLING_DIA = double.Parse(row.GetCell(48, policy).ToString());
            tpmoutr02.ROLLING_WAL_THICK = double.Parse(row.GetCell(49, policy).ToString());
            tpmoutr02.ROLLING_LEN = double.Parse(row.GetCell(50, policy).ToString());
            tpmoutr02.SRM_DIA_MIN = double.Parse(row.GetCell(51, policy).ToString());
            tpmoutr02.SRM_DIA_MAX = double.Parse(row.GetCell(52, policy).ToString());
            tpmoutr02.SRM_WAL_THICK_MIN = double.Parse(row.GetCell(53, policy).ToString());
            tpmoutr02.SRM_WAL_THICK_MAX = double.Parse(row.GetCell(54, policy).ToString());
            tpmoutr02.SRM_LEN = double.Parse(row.GetCell(55, policy).ToString());
            tpmoutr02.SAW_ABC = row.GetCell(56, policy).ToString();
            tpmoutr02.SAW_LAYER = Int32.Parse(row.GetCell(57, policy).ToString());
            tpmoutr02.SAW_LEN = double.Parse(row.GetCell(58, policy).ToString());
            tpmoutr02.SAW_CUT = Int32.Parse(row.GetCell(59, policy).ToString());
            tpmoutr02.SAW_TUBE = Int32.Parse(row.GetCell(60, policy).ToString());
            tpmoutr02.SAW_BUNDLE_WT = double.Parse(row.GetCell(61, policy).ToString());
            tpmoutr02.CUT_HEAD_LEN = double.Parse(row.GetCell(62, policy).ToString());
            tpmoutr02.CUT_TAIL_LEN = double.Parse(row.GetCell(63, policy).ToString());
            tpmoutr02.USAGE_LEN = double.Parse(row.GetCell(64, policy).ToString());
            tpmoutr02.VALID_LEN = double.Parse(row.GetCell(65, policy).ToString());
            tpmoutr02.REMAIN_LEN = double.Parse(row.GetCell(66, policy).ToString());
            tpmoutr02.DEST_CODE = row.GetCell(67, policy).ToString();
            tpmoutr02.FA_LINE_NO = row.GetCell(68, policy).ToString();
            tpmoutr02.CEC_FLAG = row.GetCell(69, policy).ToString();
            tpmoutr02.ANNEAL_FLAG = row.GetCell(70, policy).ToString();
            tpmoutr02.FIX_FLAG = row.GetCell(71, policy).ToString();
            tpmoutr02.EXPORT_FLAG = row.GetCell(72, policy).ToString();
            tpmoutr02.URG_ORDER_FLAG = row.GetCell(73, policy).ToString();
            tpmoutr02.JOINT_STUFF_FLAG = row.GetCell(74, policy).ToString();
            tpmoutr02.OIL_JOINT_FLAG = row.GetCell(75, policy).ToString();
            tpmoutr02.ULT_INSPECT_FLAG = row.GetCell(76, policy).ToString();
            tpmoutr02.SPECIAL_TOL_FLAG = row.GetCell(77, policy).ToString();
            tpmoutr02.COME_PROC_FLAG = row.GetCell(78, policy).ToString();
            tpmoutr02.REQR_ROLL_WT = double.Parse(row.GetCell(79, policy).ToString());
            tpmoutr02.REQR_BILLET_NUM = Int32.Parse(row.GetCell(80, policy).ToString());
            tpmoutr02.ORDER_CNT = Int32.Parse(row.GetCell(81, policy).ToString());
            tpmoutr02.FIX_ORDER_CNT = Int32.Parse(row.GetCell(82, policy).ToString());
            tpmoutr02.OU_BACKLOG_CODE = row.GetCell(83, policy).ToString();
            tpmoutr02.OU_BACKLOG_SEQ = Int32.Parse(row.GetCell(84, policy).ToString());
            tpmoutr02.CHECK_FLAG = row.GetCell(85, policy).ToString();
            tpmoutr02.CHECK_MAKER = row.GetCell(86, policy).ToString();
            tpmoutr02.CHECK_DATE = row.GetCell(87, policy).ToString();
            tpmoutr02.MANDRIL_HEAD_DIA = double.Parse(row.GetCell(88, policy).ToString());
            tpmoutr02.REMARK_PS = row.GetCell(89, policy).ToString();

            TPMOUTR02List.Add(tpmoutr02);
        }
    }

    /**
     * 从单个sheet里把每一行都读出来变成一个TMMTR00List
     */
    public static void fromSheetToTMMTR00List(ISheet sheet, ref List<TMMTR00> TMMTR00List)
    {
        MissingCellPolicy policy = MissingCellPolicy.CREATE_NULL_AS_BLANK;
        for (int i = 1; i <= sheet.LastRowNum; i++)
        {
            IRow row = sheet.GetRow(i);
            TMMTR00 tmmtr00 = new TMMTR00();
            tmmtr00.stat = 0;
            tmmtr00.REC_CREATOR = row.GetCell(0, policy).ToString();
            tmmtr00.REC_CREATE_TIME = row.GetCell(1, policy).ToString();
            tmmtr00.REC_REVISOR = row.GetCell(2, policy).ToString();
            tmmtr00.REC_REVISE_TIME = row.GetCell(3, policy).ToString();
            tmmtr00.REC_ERASOR = row.GetCell(4, policy).ToString();
            tmmtr00.REC_ERASE_TIME = row.GetCell(5, policy).ToString();
            tmmtr00.ARCHIVE_FLAG = row.GetCell(6, policy).ToString();
            tmmtr00.ARCHIVE_STAMP_NO = row.GetCell(7, policy).ToString();
            tmmtr00.TC_SEQ_NO = row.GetCell(8, policy).ToString();
            tmmtr00.MAT_NO = row.GetCell(9, policy).ToString();
            tmmtr00.CUST_MAT_NO = row.GetCell(10, policy).ToString();
            tmmtr00.MAT_TRACK_NO = row.GetCell(11, policy).ToString();
            tmmtr00.MAT_STATUS = row.GetCell(12, policy).ToString();
            tmmtr00.MAT_KIND = row.GetCell(13, policy).ToString();
            tmmtr00.BACKLOG_MAT_KIND = row.GetCell(14, policy).ToString();
            tmmtr00.ORIGIN_CODE = row.GetCell(15, policy).ToString();
            tmmtr00.OLD_ORIGIN_CODE = row.GetCell(16, policy).ToString();
            tmmtr00.DEST_CODE = row.GetCell(17, policy).ToString();
            tmmtr00.COME_PROC_FLAG = row.GetCell(18, policy).ToString();
            tmmtr00.MAT_NO_OLD = row.GetCell(19, policy).ToString();
            tmmtr00.ORIGIN_MAT_NO = row.GetCell(20, policy).ToString();
            tmmtr00.PURC_ORDER_NO = row.GetCell(21, policy).ToString();
            tmmtr00.VENDER_CODE = row.GetCell(22, policy).ToString();
            tmmtr00.VENDER_NAME = row.GetCell(23, policy).ToString();
            tmmtr00.VEHICLE_NO = row.GetCell(24, policy).ToString();
            tmmtr00.PONO = row.GetCell(25, policy).ToString();
            tmmtr00.CZ_RL_NO = row.GetCell(26, policy).ToString();
            tmmtr00.OLD_PONO = row.GetCell(27, policy).ToString();
            tmmtr00.BILLET_PROC_MODE_CODE = row.GetCell(28, policy).ToString();
            tmmtr00.BILLET_STRIP_CODE = row.GetCell(29, policy).ToString();
            tmmtr00.ORIGIN_HEAT_NO = row.GetCell(30, policy).ToString();
            tmmtr00.SAMPLE_LOT_NO_IN = row.GetCell(31, policy).ToString();
            tmmtr00.SEND_BATCH_NO = row.GetCell(32, policy).ToString();
            tmmtr00.ST_NO = row.GetCell(33, policy).ToString();
            tmmtr00.OLD_ST_NO = row.GetCell(34, policy).ToString();
            tmmtr00.MTRL_NO = row.GetCell(35, policy).ToString();
            tmmtr00.MTRL_TEXT = row.GetCell(36, policy).ToString();
            tmmtr00.OLD_MTRL_NO = row.GetCell(37, policy).ToString();
            tmmtr00.OLD_MTRL_TEXT = row.GetCell(38, policy).ToString();
            tmmtr00.BILLET_PSR = row.GetCell(39, policy).ToString();
            tmmtr00.BILLET_APN = row.GetCell(40, policy).ToString();
            tmmtr00.OLD_BILLET_PSR = row.GetCell(41, policy).ToString();
            tmmtr00.OLD_BILLET_APN = row.GetCell(42, policy).ToString();
            tmmtr00.COLOR_SIGN = row.GetCell(43, policy).ToString();
            tmmtr00.STD_SG_CODE = row.GetCell(44, policy).ToString();
            tmmtr00.SG_SIGN = row.GetCell(45, policy).ToString();
            tmmtr00.SG_STD = row.GetCell(46, policy).ToString();
            tmmtr00.BILLET_DIA = double.Parse(row.GetCell(47, policy).ToString());
            tmmtr00.FIX_FLAG = row.GetCell(48, policy).ToString();
            tmmtr00.LEN_FROM = double.Parse(row.GetCell(49, policy).ToString());
            tmmtr00.LEN_TO = double.Parse(row.GetCell(50, policy).ToString());
            tmmtr00.TOTAL_TUBE = Int32.Parse(row.GetCell(51, policy).ToString());
            tmmtr00.TOTAL_WT = double.Parse(row.GetCell(52, policy).ToString());
            tmmtr00.MAT_TUBE = Int32.Parse(row.GetCell(53, policy).ToString());
            tmmtr00.MAT_ACT_WT = double.Parse(row.GetCell(54, policy).ToString());
            tmmtr00.MAT_THEORY_WT = double.Parse(row.GetCell(55, policy).ToString());
            tmmtr00.BILLET_AVG_WT = double.Parse(row.GetCell(56, policy).ToString());
            tmmtr00.MAT_DISCREP_FLAG = row.GetCell(57, policy).ToString();
            tmmtr00.MAT_DISCREP_WT = double.Parse(row.GetCell(58, policy).ToString());
            tmmtr00.MAT_PLUNGE_WT = double.Parse(row.GetCell(59, policy).ToString());
            tmmtr00.PROD_TIME = row.GetCell(60, policy).ToString();
            tmmtr00.PROD_DATE = row.GetCell(61, policy).ToString();
            tmmtr00.PROD_SHIFT_NO = row.GetCell(62, policy).ToString();
            tmmtr00.PROD_SHIFT_GROUP = row.GetCell(63, policy).ToString();
            tmmtr00.PROD_MAKER = row.GetCell(64, policy).ToString();
            tmmtr00.PROD_JOB_POINT = row.GetCell(65, policy).ToString();
            tmmtr00.UNIT_CODE = row.GetCell(66, policy).ToString();
            tmmtr00.FACTORY_DIV = row.GetCell(67, policy).ToString();
            tmmtr00.FACTORY_TJ = row.GetCell(68, policy).ToString();
            tmmtr00.DEVO_TIME = row.GetCell(69, policy).ToString();
            tmmtr00.DEVO_DATE = row.GetCell(70, policy).ToString();
            tmmtr00.DEVO_SHIFT_NO = row.GetCell(71, policy).ToString();
            tmmtr00.DEVO_SHIFT_GROUP = row.GetCell(72, policy).ToString();
            tmmtr00.DEVO_MAKER = row.GetCell(73, policy).ToString();
            tmmtr00.DEVO_JOB_POINT = row.GetCell(74, policy).ToString();
            tmmtr00.STOCK_NO = row.GetCell(75, policy).ToString();
            tmmtr00.OLD_STOCK_NO = row.GetCell(76, policy).ToString();
            tmmtr00.STOCK_PLACE_NO = row.GetCell(77, policy).ToString();
            tmmtr00.STOCK_PLACE_NO_PRE = row.GetCell(78, policy).ToString();
            tmmtr00.YARD_OPERATE_TYPE = row.GetCell(79, policy).ToString();
            tmmtr00.IN_STOCK_TIME = row.GetCell(80, policy).ToString();
            tmmtr00.IN_STOCK_DATE = row.GetCell(81, policy).ToString();
            tmmtr00.IN_SHIFT_GROUP = row.GetCell(82, policy).ToString();
            tmmtr00.IN_SHIFT_NO = row.GetCell(83, policy).ToString();
            tmmtr00.IN_MAKER = row.GetCell(84, policy).ToString();
            tmmtr00.HOLD_FLAG = row.GetCell(85, policy).ToString();
            tmmtr00.HOLD_TIME = row.GetCell(86, policy).ToString();
            tmmtr00.HOLD_MAKER = row.GetCell(87, policy).ToString();
            tmmtr00.HOLD_CAUSE_CODE = row.GetCell(88, policy).ToString();
            tmmtr00.HOLD_REMARK = row.GetCell(89, policy).ToString();
            tmmtr00.REL_TIME = row.GetCell(90, policy).ToString();
            tmmtr00.REL_MAKER = row.GetCell(91, policy).ToString();
            tmmtr00.REL_REMARK = row.GetCell(92, policy).ToString();
            tmmtr00.SCRAP_TIME = row.GetCell(93, policy).ToString();
            tmmtr00.SCRAP_MAKER = row.GetCell(94, policy).ToString();
            tmmtr00.SCRAP_CAUSE_CODE = row.GetCell(95, policy).ToString();
            tmmtr00.SCRAP_REMARK = row.GetCell(96, policy).ToString();
            tmmtr00.REMAIN_CAUSE_CODE = row.GetCell(97, policy).ToString();
            tmmtr00.REMAIN_DECIDE_TIME = row.GetCell(98, policy).ToString();
            tmmtr00.REMAIN_DECIDE_MAKER = row.GetCell(99, policy).ToString();
            tmmtr00.REMAIN_REMARK = row.GetCell(100, policy).ToString();
            tmmtr00.PLAN_NO = row.GetCell(101, policy).ToString();
            tmmtr00.PLAN_SEQ_NO = Int32.Parse(row.GetCell(102, policy).ToString());
            tmmtr00.OUT_ORDER_NO = row.GetCell(103, policy).ToString();
            tmmtr00.OUT_TYPE_CODE = row.GetCell(104, policy).ToString();
            tmmtr00.OUT_TYPE_DESC = row.GetCell(105, policy).ToString();
            tmmtr00.OUT_TASK_DESC = row.GetCell(106, policy).ToString();
            tmmtr00.OUT_TASK_NO = row.GetCell(107, policy).ToString();
            tmmtr00.OUT_UNIT_CODE = row.GetCell(108, policy).ToString();
            tmmtr00.OUT_UNIT_NAME = row.GetCell(109, policy).ToString();
            tmmtr00.REMARK_PS = row.GetCell(110, policy).ToString();
            tmmtr00.RL_NO = row.GetCell(111, policy).ToString();
            tmmtr00.OLD_RL_NO = row.GetCell(112, policy).ToString();
            tmmtr00.RL_ITEM_NO = row.GetCell(113, policy).ToString();
            tmmtr00.ROLL_DIA = double.Parse(row.GetCell(114, policy).ToString());
            tmmtr00.ROLL_WAL_THICK = double.Parse(row.GetCell(115, policy).ToString());
            tmmtr00.RL_BILLET_LEN = Int32.Parse(row.GetCell(116, policy).ToString());
            tmmtr00.RL_BILLET_WT = double.Parse(row.GetCell(117, policy).ToString());
            tmmtr00.RL_ST_NO = row.GetCell(118, policy).ToString();
            tmmtr00.RL_MTRL_NO = row.GetCell(119, policy).ToString();
            tmmtr00.RL_MTRL_TEXT = row.GetCell(120, policy).ToString();
            tmmtr00.ACCOUNT_GROUP = row.GetCell(121, policy).ToString();
            tmmtr00.PRE_PRODUCT_CODE = row.GetCell(122, policy).ToString();
            tmmtr00.PRODUCT_CODE = row.GetCell(123, policy).ToString();
            tmmtr00.AI_TIME = row.GetCell(124, policy).ToString();
            tmmtr00.PRODUCT_CODE_1 = row.GetCell(125, policy).ToString();
            tmmtr00.AI_TIME_1 = row.GetCell(126, policy).ToString();
            tmmtr00.AI_WT_1 = double.Parse(row.GetCell(127, policy).ToString());
            tmmtr00.COST_CENTER_1 = row.GetCell(128, policy).ToString();
            tmmtr00.ACTT_ITEM_1 = row.GetCell(129, policy).ToString();
            tmmtr00.PRODUCT_CODE_2 = row.GetCell(130, policy).ToString();
            tmmtr00.AI_TIME_2 = row.GetCell(131, policy).ToString();
            tmmtr00.AI_WT_2 = double.Parse(row.GetCell(132, policy).ToString());
            tmmtr00.COST_CENTER_2 = row.GetCell(133, policy).ToString();
            tmmtr00.ACTT_ITEM_2 = row.GetCell(134, policy).ToString();
            tmmtr00.PRODUCT_CODE_3 = row.GetCell(135, policy).ToString();
            tmmtr00.AI_TIME_3 = row.GetCell(136, policy).ToString();
            tmmtr00.AI_WT_3 = double.Parse(row.GetCell(137, policy).ToString());
            tmmtr00.COST_CENTER_3 = row.GetCell(138, policy).ToString();
            tmmtr00.ACTT_ITEM_3 = row.GetCell(139, policy).ToString();
            tmmtr00.AI_DIF_FLAG = row.GetCell(140, policy).ToString();
            tmmtr00.AC_ROUTE = row.GetCell(141, policy).ToString();
            tmmtr00.OUT_AI_FLAG = row.GetCell(142, policy).ToString();
            tmmtr00.KEYVALUE_1 = row.GetCell(143, policy).ToString();
            tmmtr00.KEYVALUE_2 = row.GetCell(144, policy).ToString();
            tmmtr00.KEYVALUE_3 = row.GetCell(145, policy).ToString();
            tmmtr00.KEYVALUE_4 = row.GetCell(146, policy).ToString();
            tmmtr00.KEYVALUE_5 = row.GetCell(147, policy).ToString();

            TMMTR00List.Add(tmmtr00);
        }
    }

    /**
     * 从单个sheet里把每一行都读出来变成一个actualCutResultList
     */
    public static void fromSheetToActualCutResultList(ISheet sheet, ref List<ActualCutResult> actualCutResultList)
    {
        MissingCellPolicy policy = MissingCellPolicy.CREATE_NULL_AS_BLANK;
        for (int i = 1; i < sheet.LastRowNum; i++)
        {
            IRow row = sheet.GetRow(i);
            ActualCutResult actualCutResult = new ActualCutResult();

            actualCutResult.CUT_DATE = row.GetCell(1, policy).ToString();
            actualCutResult.CUT_TIME = row.GetCell(2, policy).ToString();
            actualCutResult.SHIFT_NO = int.Parse(row.GetCell(3, policy).ToString());
            actualCutResult.CLASS_NO = int.Parse(row.GetCell(4, policy).ToString());
            actualCutResult.RL_NO = row.GetCell(5, policy).ToString();
            actualCutResult.ROLL_DIA = double.Parse(row.GetCell(6, policy).ToString());
            actualCutResult.ROLL_WAL_THICK = double.Parse(row.GetCell(7, policy).ToString());
            actualCutResult.PONO = row.GetCell(8, policy).ToString();
            actualCutResult.MTRL_NO = row.GetCell(9, policy).ToString();
            actualCutResult.MTRL_TEXT = row.GetCell(10, policy).ToString();
            actualCutResult.FIX_FLAG = int.Parse(row.GetCell(11, policy).ToString());
            actualCutResult.CUT_LEN = double.Parse(row.GetCell(12, policy).ToString());
            actualCutResult.MAT_LEN = double.Parse(row.GetCell(13, policy).ToString());
            actualCutResult.MAT_TUBE = int.Parse(row.GetCell(14, policy).ToString());
            actualCutResult.REMAIN_LEN = double.Parse(row.GetCell(15, policy).ToString());
            actualCutResult.REMAIN_BILLET = int.Parse(row.GetCell(16, policy).ToString());
            actualCutResult.REMOVE_TUBE = int.Parse(row.GetCell(17, policy).ToString());
            actualCutResult.CUT_BILLET = int.Parse(row.GetCell(18, policy).ToString());
            actualCutResult.CUT_WEIGHT = double.Parse(row.GetCell(19, policy).ToString());
            actualCutResult.BILLET_DIA = double.Parse(row.GetCell(20, policy).ToString());
            actualCutResult.STOCK_PLACE_NO = row.GetCell(21, policy).ToString();
            actualCutResult.PROD_MID_CNAME = row.GetCell(22, policy).ToString();

            actualCutResultList.Add(actualCutResult);
        }
    }


    /**
     * 将单个List中的内容写入一个Sheet中
     */
    public static void fromRateOfRecordListToSheet(ref ISheet sheet, List<RateOfRecord> rateOfRecordList)
    {
        // 标题
        string[] columnNames = new[]
        {
            "材质号", "轧批号", "计划序号", "直径", "计划坯长", "计划根数", "计划重量", "计划坯长收得率", "交货长度起", "交货长度止", "", "投料日期", "时间",
            "炉号", "库位", "定尺标记", "棒材长度", "棒材投料根数", "投料重量", "正料长度", "正料个数", "余料长度", "余料个数", "实际收得率", "实际坯长均值", "相对完成重量",
            "相对收得率", "相对坯长均值", "备注", "", "正料有效长度", "正料锯切长度", "正料剩余长度", "余料有效长度", "余料剩余长度", "正料锯切个数", "余料锯切个数", "正料带料",
            "余料带料", "一根棒材能得到的成品根数", "拉伸系数"
        };
        IRow row1 = sheet.CreateRow(0);
        createSheetColumnNames(ref row1, columnNames);

        // 内容
        for (int i = 1; i < rateOfRecordList.Count; i++)
        {
            IRow row = sheet.CreateRow(i);
            row.CreateCell(0).SetCellValue(rateOfRecordList[i].MTRL_NO);
            row.CreateCell(1).SetCellValue(rateOfRecordList[i].RL_NO);
            row.CreateCell(2).SetCellValue(rateOfRecordList[i].PLAN_SEQ_NO);
            row.CreateCell(3).SetCellValue(rateOfRecordList[i].BILLET_DIA);
            row.CreateCell(4).SetCellValue(rateOfRecordList[i].BILLET_LEN);
            row.CreateCell(5).SetCellValue(rateOfRecordList[i].REQR_ROLL_TUBE);
            row.CreateCell(6).SetCellValue(rateOfRecordList[i].REQR_ROLL_WT);
            row.CreateCell(7).SetCellValue(rateOfRecordList[i].RATE);
            row.CreateCell(8).SetCellValue(rateOfRecordList[i].LEN_FROM);
            row.CreateCell(9).SetCellValue(rateOfRecordList[i].LEN_TO);
            // 空一格
            row.CreateCell(10).SetCellValue("");
            row.CreateCell(11).SetCellValue(rateOfRecordList[i].CUT_DATE);
            row.CreateCell(12).SetCellValue(rateOfRecordList[i].CUT_TIME);
            row.CreateCell(13).SetCellValue(rateOfRecordList[i].PONO);
            row.CreateCell(14).SetCellValue(rateOfRecordList[i].STOCK_PLACE_NO);
            row.CreateCell(15).SetCellValue(rateOfRecordList[i].FIX_FLAG);
            row.CreateCell(16).SetCellValue(rateOfRecordList[i].MAT_LEN);
            row.CreateCell(17).SetCellValue(rateOfRecordList[i].MAT_TUBE);
            row.CreateCell(18).SetCellValue(rateOfRecordList[i].CUT_WEIGHT);
            row.CreateCell(19).SetCellValue(rateOfRecordList[i].CUT_LEN);
            row.CreateCell(20).SetCellValue(rateOfRecordList[i].CUT_BILLET);
            row.CreateCell(21).SetCellValue(rateOfRecordList[i].REMAIN_LEN);
            row.CreateCell(22).SetCellValue(rateOfRecordList[i].REMAIN_BILLET);
            row.CreateCell(23).SetCellValue(rateOfRecordList[i].ACTUAL_RATE);
            row.CreateCell(24).SetCellValue(rateOfRecordList[i].ACTUAL_AVG_L2);
            row.CreateCell(25).SetCellValue(rateOfRecordList[i].COMP_WEIGHT);
            row.CreateCell(26).SetCellValue(rateOfRecordList[i].COMP_RATE);
            row.CreateCell(27).SetCellValue(rateOfRecordList[i].COMP_AVG_L2);
            
            row.CreateCell(28).SetCellValue(rateOfRecordList[i].REMARK);
            // 空一格
            row.CreateCell(29).SetCellValue("");
            
            
            row.CreateCell(30).SetCellValue(rateOfRecordList[i].CUT_VALID);
            row.CreateCell(31).SetCellValue(rateOfRecordList[i].A_SAW_LEN);
            row.CreateCell(32).SetCellValue(rateOfRecordList[i].A_REMAIN_LEN);
            row.CreateCell(33).SetCellValue(rateOfRecordList[i].REMAIN_VALID);
            row.CreateCell(34).SetCellValue(rateOfRecordList[i].SP_REMAIN_LEN);
            row.CreateCell(35).SetCellValue(rateOfRecordList[i].A_SAW_NUM);
            row.CreateCell(36).SetCellValue(rateOfRecordList[i].SP_SAW_NUM);
            row.CreateCell(37).SetCellValue(rateOfRecordList[i].A_REPLACE);
            row.CreateCell(38).SetCellValue(rateOfRecordList[i].SP_REPLACE);
            row.CreateCell(39).SetCellValue(rateOfRecordList[i].TOTAL_NUML4);
            row.CreateCell(40).SetCellValue(rateOfRecordList[i].EXTEND4);
        }
    }

    /**
     * 将单个List中的内容写入一个Sheet中
     */
    public static void fromRateOfPlanListListToSheet(ref ISheet sheet, List<RateOfPlan> rateOfPlanList)
    {
        // 标题
        string[] columnNames = new[]
        {
            "材质号", "轧批号", "计划序号", "直径", "计划坯长", "计划根数", "计划重量", "计划坯长收得率", "交货长度起", "交货长度止", "计划成品根数", "投料重量", "实际收得率",
            "实际坯长均值", "相对完成重量", "相对收得率", "相对坯长均值", "备注"
        };
        IRow row1 = sheet.CreateRow(0);
        createSheetColumnNames(ref row1, columnNames);

        // 内容
        for (int i = 1; i < rateOfPlanList.Count; i++)
        {
            IRow row = sheet.CreateRow(i);
            row.CreateCell(0).SetCellValue(rateOfPlanList[i].MTRL_NO);
            row.CreateCell(1).SetCellValue(rateOfPlanList[i].RL_NO);
            row.CreateCell(2).SetCellValue(rateOfPlanList[i].PLAN_SEQ_NO);
            row.CreateCell(3).SetCellValue(rateOfPlanList[i].BILLET_DIA);
            row.CreateCell(4).SetCellValue(rateOfPlanList[i].BILLET_LEN);
            row.CreateCell(5).SetCellValue(rateOfPlanList[i].REQR_ROLL_TUBE);
            row.CreateCell(6).SetCellValue(rateOfPlanList[i].REQR_ROLL_WT);
            row.CreateCell(7).SetCellValue(rateOfPlanList[i].RATE);
            row.CreateCell(8).SetCellValue(rateOfPlanList[i].LEN_FROM);
            row.CreateCell(9).SetCellValue(rateOfPlanList[i].LEN_TO);
            row.CreateCell(10).SetCellValue(rateOfPlanList[i].CUT_WEIGHT);
            row.CreateCell(11).SetCellValue(rateOfPlanList[i].ACTUAL_RATE);
            row.CreateCell(12).SetCellValue(rateOfPlanList[i].ACTUAL_AVG_L2);
            row.CreateCell(13).SetCellValue(rateOfPlanList[i].COMP_WEIGHT);
            row.CreateCell(14).SetCellValue(rateOfPlanList[i].COMP_RATE);
            row.CreateCell(15).SetCellValue(rateOfPlanList[i].COMP_AVG_L2);
            row.CreateCell(16).SetCellValue(rateOfPlanList[i].REMARK);
            
        }
    }

    /**
     * 将单个List中的内容写入一个Sheet中
     */
    public static void fromRateOfAllListToSheet(ref ISheet sheet, List<RateOfAll> rateOfAllList)
    {
        // 标题
        string[] columnNames = new[]
        {
            "计划总重量", "投料重量", "整体实际收得率", "整体实际坯长均值", "相对完成总重量", "整体相对收得率", "整体平均产能" 
        };
        IRow row1 = sheet.CreateRow(0);
        createSheetColumnNames(ref row1, columnNames);

        // 内容
        for (int i = 1; i < rateOfAllList.Count; i++)
        {
            IRow row = sheet.CreateRow(i);
            row.CreateCell(0).SetCellValue(rateOfAllList[i].REQR_ROLL_WT);
            row.CreateCell(1).SetCellValue(rateOfAllList[i].CUT_WEIGHT);
            row.CreateCell(2).SetCellValue(rateOfAllList[i].ACTUAL_RATE);
            row.CreateCell(3).SetCellValue(rateOfAllList[i].ACTUAL_AVG_L2);
            row.CreateCell(4).SetCellValue(rateOfAllList[i].COMP_WEIGHT);
            row.CreateCell(5).SetCellValue(rateOfAllList[i].COMP_RATE);
            row.CreateCell(6).SetCellValue(rateOfAllList[i].COMP_AVG_L2);
        }
    }

    /**
     * 单个sheet首行是列名称
     */
    private static void createSheetColumnNames(ref IRow row1, string[] columnNames)
    {
        for (int i = 0; i < columnNames.Length; i++)
        {
            row1.CreateCell(i).SetCellValue(columnNames[i]);
        }
    }
}